// 更改 Vuex 的 store 中的状态的唯一方法是提交 mutation
// this.$store.commit(method, params)
import Cookies from 'js-cookie'
export default {

    /** 设置token */
    SET_TOKEN: (state, token) => {
        state.token = token
    },

    /** 设置用户名 */
    SET_NAME: (state, name) => {
        state.name = name
    },

    /** 设置头像 */
    SET_AVATAR: (state, avatar) => {
        state.avatar = avatar
    },

    /** 设置菜单 */
    SET_MENU: (state, list) => {
        state.menu = list
    },

    // 设置权限列表
    SET_PERMISSION: (state, list) => {
        state.permission = list;
    },

    // 设置当前页面权限
    SET_CURRENT_PERMISSION: (state, list) => {
        state.currentPermission = list
    },

    /** 设置路由 */
    SET_ROUTES: (state, list) => {
        state.routes = list
    },

    TOGGLE_SIDEBAR: state => {
        state.sidebar.opened = !state.sidebar.opened
        state.sidebar.withoutAnimation = false
        if (state.sidebar.opened) {
            Cookies.set('sidebarStatus', 1)
        } else {
            Cookies.set('sidebarStatus', 0)
        }
    },
    CLOSE_SIDEBAR: (state, withoutAnimation) => {
        Cookies.set('sidebarStatus', 0)
        state.sidebar.opened = false
        state.sidebar.withoutAnimation = withoutAnimation
    },
    TOGGLE_DEVICE: (state, device) => {
        state.device = device
    },

    CHANGE_SETTING: (state, { key, value }) => {
        if (state.hasOwnProperty(key)) {
            state[key] = value
        }
    },


    // 设置城市
    SET_CITY_LIST: (state, list) => {
        state.cityList = list;
    },

    // 设置项目 需求
    SET_PROJECT_LIST: (state, list) => {
        state.projectList = list
    },

    // 设置负责人
    SET_USER_LIST: (state, list) => {
        state.userList = list
    },

    // 设置广告代号
    SET_ADCODE_LIST: (state, list) => {
        state.adCodeList = list
    },

    // 设置医院列表
    SET_HOSPITAL_LIST: (state, list) => {
        state.hospitalList = list
    },

    // 设置用户来源
    SET_SOURCE_LIST: (state, list) => {
        state.sourceList = list
    },

    // 设置文章分类
    SET_ARTICLECLASS_LIST: (state, list) => {
        state.articleClassList = list
    },

    // 设置医院资质
    SET_HOSPITAL_CERTIFICATION_LIST: (state, list) => {
        state.hospCertificationList = list
    },

    // 设置医院类型
    SET_HOSPCLASS_LIST: (state, list) => {
        state.hospClassList = list
    },

    // 设置医生列表
    SET_DOCTOR_LIST: (state, list) => {
        state.doctorList = list
    },

    // 设置商品列表
    SET_GOODS_LIST:(state, list)=>{
        state.goodsList = list
    }


}
